﻿/*
 * This file is part of quickReminder, a software for gamers
 *
 * Copyright (C) 2006-2009 Lucas Romero
 *
 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
using System.IO;

using ICSharpCode.SharpZipLib.Zip;

using LucasCode.PublicTypes;

namespace LucasCode.Tools
{
    public static class DiskIO
    {
        private static FileInfo m_FileInfo = null;

        public static void checkPathexists(string filename)
        {
            if (!Directory.Exists(Path.GetDirectoryName(filename)))
                Directory.CreateDirectory(Path.GetDirectoryName(filename));
        }

        public static bool checkFileExists(string filename)
        {
            if (File.Exists(filename))
                return true;
            else
                return false;
        }

        public static bool checkFileInfoExists(MatchFile file)
        {
            m_FileInfo = new FileInfo(file.Filename);
            if (m_FileInfo.Exists)
                return true;
            else
                return false;
        }

        public static string loadTextFromFile(string path)
        {
            string result = string.Empty;

            StreamReader reader = new StreamReader(path);

            result = reader.ReadToEnd();

            return result;
        }

        public static FileInfo FileInfo
        {
            get { return m_FileInfo; }
        }

        public static string getPath(string filename)
        {
            return Path.GetDirectoryName(Path.GetFullPath(filename));
        }

        public static string getExtension(string filename)
        {
            return Path.GetExtension(filename);
        }
    }
}
